home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / tm-88k.h < prev    next >
C/C++ Source or Header  |  1992-09-11  |  15KB  |  482 lines

  1. /* Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  2.  
  3. This file is part of GDB.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. /* This is currently for a 88000 running DGUX.  If other 88k ports are
  20.    done, OS-specific stuff should be moved (see tm-68k.h, for example).  */
  21. /* g++ support is not yet included.  */
  22.  
  23. #include "tdesc.h"
  24.  
  25. #if !defined (DGUX)
  26. #define DGUX 1
  27. #endif
  28.  
  29. #define TARGET_BYTE_ORDER BIG_ENDIAN
  30.  
  31. #define EXTRA_SYMTAB_INFO int coffsem;
  32.  
  33. /* This is not a CREATE_INFERIOR_HOOK because it also applies to
  34.    remote debugging.  */
  35. #define START_INFERIOR_HOOK() \
  36.   { \
  37.     extern int safe_to_init_tdesc_context; \
  38.     extern dc_handle_t tdesc_handle; \
  39.  \
  40.     safe_to_init_tdesc_context = 0; \
  41.     if (tdesc_handle) \
  42.       { \
  43.     dc_terminate (tdesc_handle); \
  44.     tdesc_handle = 0; \
  45.       } \
  46.   }
  47.  
  48. dc_dcontext_t get_prev_context ();
  49. extern int stack_error;
  50.  
  51. #define EXTRA_FRAME_INFO dc_dcontext_t frame_context;
  52. #define INIT_EXTRA_FRAME_INFO(fci) \
  53.   {                                     \
  54.     if (fci->next_frame != NULL)                     \
  55.       {                                 \
  56.         extern jmp_buf stack_jmp;                     \
  57.         struct frame_info *next_frame = fci->next;                       \
  58.         /* The call to get_prev_context */                 \
  59.         /* will update current_context for us. */             \
  60.         stack_error = 1;                         \
  61.         if (!setjmp (stack_jmp))                     \
  62.           {                                 \
  63.             fci->frame_context                     \
  64.               = get_prev_context (next_frame->frame_context);         \
  65.             stack_error = 0;                         \
  66.           }                                 \
  67.         else                                 \
  68.           {                                 \
  69.             stack_error = 0;                         \
  70.             next_frame->prev = 0;                     \
  71.             return 0;                             \
  72.           }                                   \
  73.         if (!fci->frame_context)                     \
  74.           {                                 \
  75.             next_frame->prev = 0;                     \
  76.             return 0;                             \
  77.           }                                 \
  78.       }                                 \
  79.     else                                 \
  80.       {                                 \
  81.         /* We are creating an arbitrary frame */             \
  82.         /* (i.e. we are in create_new_frame).  */             \
  83.         extern dc_dcontext_t current_context;                 \
  84.                                         \
  85.         fci->frame_context = current_context;                 \
  86.       }                                 \
  87.   }
  88.  
  89. #define INIT_FRAME_PC(fromleaf, prev) \
  90.   {                                     \
  91.     prev->pc = dc_location (prev->frame_context);             \
  92.     prev->frame = get_frame_base (prev->pc);                                        \
  93.   }
  94.  
  95. #define IEEE_FLOAT
  96.  
  97. /* Text Description (TDESC) is used by m88k to maintain stack & reg info */
  98.  
  99. #define TDESC
  100.  
  101. /* Define this if the C compiler puts an underscore at the front
  102.    of external names before giving them to the linker.  */
  103.  
  104. #define NAMES_HAVE_UNDERSCORE
  105.  
  106. /* Hook for read_relative_register_raw_bytes */
  107.  
  108. #define READ_RELATIVE_REGISTER_RAW_BYTES
  109.  
  110. /* Offset from address of function to start of its code.
  111.    Zero on most machines.  */
  112.  
  113. #define FUNCTION_START_OFFSET 0
  114.  
  115. /* Advance PC across any function entry prologue instructions
  116.    to reach some "real" code.  */
  117.  
  118. #define SKIP_PROLOGUE(frompc)   0
  119.  
  120. /* The m88k kernel aligns all instructions on 4-byte boundaries.  The
  121.    kernel also uses the least significant two bits for its own hocus
  122.    pocus.  When gdb receives an address from the kernel, it needs to
  123.    preserve those right-most two bits, but gdb also needs to be careful
  124.    to realize that those two bits are not really a part of the address
  125.    of an instruction.  Shrug.  */
  126.  
  127. #define ADDR_BITS_REMOVE(addr) ((addr) & ~3)
  128. #define ADDR_BITS_SET(addr) (((addr) | 0x00000002) - 4)
  129.  
  130. /* Immediately after a function call, return the saved pc.
  131.    Can't always go through the frames for this because on some machines
  132.    the new frame is not set up until the new function executes
  133.    some instructions.  */
  134.  
  135. #define SAVED_PC_AFTER_CALL(frame) \
  136.   (read_register (SRP_REGNUM) & (~3))
  137.  
  138. /* Address of end of stack space.  */
  139.  
  140. #define STACK_END_ADDR 0xF0000000
  141.  
  142. /* Stack grows downward.  */
  143.  
  144. #define INNER_THAN <
  145.  
  146. /* Sequence of bytes for breakpoint instruction.  */
  147.  
  148. /* instruction 0xF000D1FF is 'tb0 0,r0,511'
  149.    If Bit bit 0 of r0 is clear (always true),
  150.    initiate exception processing (trap).
  151.  */
  152. #define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF}
  153.  
  154. /* Address of end of stack space.  */
  155.  
  156. #define STACK_END_ADDR 0xF0000000
  157.  
  158. /* Stack grows downward.  */
  159.  
  160. #define INNER_THAN <
  161.  
  162. /* Sequence of bytes for breakpoint instruction.  */
  163.  
  164. /* instruction 0xF000D1FF is 'tb0 0,r0,511'
  165.    If Bit bit 0 of r0 is clear (always true),
  166.    initiate exception processing (trap).
  167.  */
  168. #define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF}
  169.  
  170. /* Amount PC must be decremented by after a breakpoint.
  171.    This is often the number of bytes in BREAKPOINT
  172.    but not always.  */
  173.  
  174. #define DECR_PC_AFTER_BREAK 0
  175.  
  176. /* Nonzero if instruction at PC is a return instruction.  */
  177. /* 'jmp r1' or 'jmp.n r1' is used to return from a subroutine. */
  178.  
  179. #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0xF800)
  180.  
  181. /* Return 1 if P points to an invalid floating point value.
  182.    LEN is the length in bytes -- not relevant on the 386.  */
  183.  
  184. #define INVALID_FLOAT(p, len) IEEE_isNAN(p,len)
  185.  
  186. /* Say how long (ordinary) registers are.  */
  187.  
  188. #define REGISTER_TYPE long
  189.  
  190. /* Number of machine registers */
  191.  
  192. #define NUM_REGS 38
  193.  
  194. /* Initializer for an array of names of registers.
  195.    There should be NUM_REGS strings in this initializer.  */
  196.  
  197. #define REGISTER_NAMES {\
  198.      "r0",\
  199.     "r1",\
  200.     "r2",\
  201.     "r3",\
  202.     "r4",\
  203.     "r5",\
  204.     "r6",\
  205.     "r7",\
  206.     "r8",\
  207.     "r9",\
  208.     "r10",\
  209.     "r11",\
  210.     "r12",\
  211.     "r13",\
  212.     "r14",\
  213.     "r15",\
  214.     "r16",\
  215.     "r17",\
  216.     "r18",\
  217.     "r19",\
  218.     "r20",\
  219.     "r21",\
  220.     "r22",\
  221.     "r23",\
  222.     "r24",\
  223.     "r25",\
  224.     "r26",\
  225.     "r27",\
  226.     "r28",\
  227.     "r29",\
  228.     "r30",\
  229.     "r31",\
  230.     "psr",\
  231.     "fpsr",\
  232.     "fpcr",\
  233.     "sxip",\
  234.     "snip",\
  235.     "sfip",\
  236.     "vbr",\
  237.     "dmt0",\
  238.     "dmd0",\
  239.     "dma0",\
  240.     "dmt1",\
  241.     "dmd1",\
  242.     "dma1",\
  243.     "dmt2",\
  244.     "dmd2",\
  245.     "dma2",\
  246.     "sr0",\
  247.     "sr1",\
  248.     "sr2",\
  249.     "sr3",\
  250.     "fpecr",\
  251.     "fphs1",\
  252.     "fpls1",\
  253.     "fphs2",\
  254.     "fpls2",\
  255.     "fppt",\
  256.     "fprh",\
  257.     "fprl",\
  258.     "fpit",\
  259.     "fpsr",\
  260.     "fpcr",\
  261.     };
  262.  
  263.  
  264. /* Register numbers of various important registers.
  265.    Note that some of these values are "real" register numbers,
  266.    and correspond to the general registers of the machine,
  267.    and some are "phony" register numbers which are too large
  268.    to be actual register numbers as far as the user is concerned
  269.    but do serve to get the desired values when passed to read_register.  */
  270.  
  271. #define SRP_REGNUM 1        /* Contains subroutine return pointer */
  272. #define RV_REGNUM 2        /* Contains simple return values */
  273. #define SRA_REGNUM 12        /* Contains address of struct return values */
  274. #define FP_REGNUM 30        /* Contains address of executing stack frame */
  275. #define SP_REGNUM 31        /* Contains address of top of stack */
  276. #define SXIP_REGNUM 35        /* Contains Shadow Execute Instruction Pointer */
  277. #define SNIP_REGNUM 36        /* Contains Shadow Next Instruction Pointer */
  278. #define PC_REGNUM SXIP_REGNUM    /* Program Counter */
  279. #define NPC_REGNUM SNIP_REGNUM    /* Next Program Counter */
  280. #define PSR_REGNUM 32           /* Processor Status Register */
  281. #define FPSR_REGNUM 33        /* Floating Point Status Register */
  282. #define FPCR_REGNUM 34        /* Floating Point Control Register */
  283. #define SFIP_REGNUM 37        /* Contains Shadow Fetched Intruction pointer */
  284. #define NNPC_REGNUM SFIP_REGNUM /* Next Next Program Counter */
  285.  
  286. /* PSR status bit definitions.  */
  287.  
  288. #define PSR_MODE        0x80000000
  289. #define PSR_BYTE_ORDER        0x40000000
  290. #define PSR_SERIAL_MODE        0x20000000
  291. #define PSR_CARRY        0x10000000
  292. #define PSR_SFU_DISABLE        0x000003f0
  293. #define PSR_SFU1_DISABLE    0x00000008
  294. #define PSR_MXM            0x00000004
  295. #define PSR_IND            0x00000002
  296. #define PSR_SFRZ        0x00000001
  297.  
  298. /* BCS requires that the SXIP_REGNUM (or PC_REGNUM) contain the address
  299.    of the next instr to be executed when a breakpoint occurs.  Because
  300.    the kernel gets the next instr (SNIP_REGNUM), the instr in SNIP needs
  301.    to be put back into SFIP, and the instr in SXIP should be shifted
  302.    to SNIP */
  303.  
  304. /* Are you sitting down?  It turns out that the 88K BCS (binary compatibility
  305.   standard) folks originally felt that the debugger should be responsible
  306.   for backing up the IPs, not the kernel (as is usually done).  Well, they
  307.   have reversed their decision, and in future releases our kernel will be
  308.   handling the backing up of the IPs.  So, eventually, we won't need to
  309.   do the SHIFT_INST_REGS stuff.  But, for now, since there are 88K systems out
  310.   there that do need the debugger to do the IP shifting, and since there
  311.   will be systems where the kernel does the shifting, the code is a little
  312.   more complex than perhaps it needs to be (we still go inside SHIFT_INST_REGS,
  313.   and if the shifting hasn't occurred then gdb goes ahead and shifts).  */
  314.  
  315. #define SHIFT_INST_REGS
  316.  
  317. /* Total amount of space needed to store our copies of the machine's
  318.    register state, the array `registers'.  */
  319.  
  320. #define REGISTER_BYTES (NUM_REGS * sizeof(REGISTER_TYPE))
  321.  
  322. /* Index within `registers' of the first byte of the space for
  323.    register N.  */
  324.  
  325. #define REGISTER_BYTE(N) ((N)*sizeof(REGISTER_TYPE))
  326.  
  327. /* Number of bytes of storage in the actual machine representation
  328.    for register N.  */
  329.  
  330. #define REGISTER_RAW_SIZE(N) (sizeof(REGISTER_TYPE))
  331.  
  332. /* Number of bytes of storage in the program's representation
  333.    for register N. */
  334.  
  335. #define REGISTER_VIRTUAL_SIZE(N) (sizeof(REGISTER_TYPE))
  336.  
  337. /* Largest value REGISTER_RAW_SIZE can have.  */
  338.  
  339. #define MAX_REGISTER_RAW_SIZE (sizeof(REGISTER_TYPE))
  340.  
  341. /* Largest value REGISTER_VIRTUAL_SIZE can have.
  342. /* Are FPS1, FPS2, FPR "virtual" regisers? */
  343.  
  344. #define MAX_REGISTER_VIRTUAL_SIZE (sizeof(REGISTER_TYPE))
  345.  
  346. /* Nonzero if register N requires conversion
  347.    from raw format to virtual format.  */
  348.  
  349. #define REGISTER_CONVERTIBLE(N) (0)
  350.  
  351. /* Convert data from raw format for register REGNUM
  352.    to virtual format for register REGNUM.  */
  353.  
  354. #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), (sizeof(REGISTER_TYPE)));}
  355.  
  356. /* Convert data from virtual format for register REGNUM
  357.    to raw format for register REGNUM.  */
  358.  
  359. #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), (sizeof(REGISTER_TYPE)));}
  360.  
  361. /* Return the GDB type object for the "standard" data type
  362.    of data in register N.  */
  363.  
  364. #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
  365.  
  366. /* The 88k call/return conventions call for "small" values to be returned
  367.    into consecutive registers starting from r2.  */
  368.  
  369. #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
  370.   bcopy (&(((char *)REGBUF)[REGISTER_BYTE(RV_REGNUM)]), (VALBUF), TYPE_LENGTH (TYPE))
  371.  
  372. #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
  373.  
  374. /* Write into appropriate registers a function return value
  375.    of type TYPE, given in virtual format.  */
  376.  
  377. #define STORE_RETURN_VALUE(TYPE,VALBUF) \
  378.   write_register_bytes (2*sizeof(void*), (VALBUF), TYPE_LENGTH (TYPE))
  379.  
  380. /* In COFF, if PCC says a parameter is a short or a char, do not
  381.    change it to int (it seems the convention is to change it). */
  382.  
  383. #define BELIEVE_PCC_PROMOTION 1
  384.  
  385. /* We provide our own get_saved_register in m88k-tdep.c.  */
  386. #define GET_SAVED_REGISTER
  387.  
  388. /* Describe the pointer in each stack frame to the previous stack frame
  389.    (its caller).  */
  390.  
  391. /* FRAME_CHAIN takes a frame's nominal address
  392.    and produces the frame's chain-pointer.
  393.  
  394.    FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
  395.    and produces the nominal address of the caller frame.
  396.  
  397.    However, if FRAME_CHAIN_VALID returns zero,
  398.    it means the given frame is the outermost one and has no caller.
  399.    In that case, FRAME_CHAIN_COMBINE is not used.  */
  400.  
  401. /* These are just dummies for the 88k because INIT_FRAME_PC sets prev->frame
  402.    instead.  */
  403.  
  404. #define FRAME_CHAIN(thisframe) (0)
  405.  
  406. #define FRAME_CHAIN_VALID(chain, thisframe) (1)
  407.  
  408. #define FRAME_CHAIN_COMBINE(chain, thisframe) (0)
  409.  
  410. /* Define other aspects of the stack frame.  */
  411.  
  412. #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame+4, 4))
  413.  
  414. #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
  415.  
  416. #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
  417.  
  418. /* Return number of args passed to a frame.
  419.    Can return -1, meaning no way to tell.  */
  420.  
  421. #define FRAME_NUM_ARGS(numargs, fi)  ((numargs) = -1)
  422.  
  423. /* Return number of bytes at start of arglist that are not really args.  */
  424.  
  425. #define FRAME_ARGS_SKIP 0
  426.  
  427. /* Put here the code to store, into a struct frame_saved_regs,
  428.    the addresses of the saved registers of frame described by FRAME_INFO.
  429.    This includes special registers such as pc and fp saved in special
  430.    ways in the stack frame.  sp is even more special:
  431.    the address we return for it IS the sp for the next frame.  */
  432.  
  433. /* On the 88k, parameter registers get stored into the so called "homing"
  434.    area.  This *always* happens when you compiled with GCC and use -g.
  435.    Also, (with GCC and -g) the saving of the parameter register values
  436.    always happens right within the function prologue code, so these register
  437.    values can generally be relied upon to be already copied into their
  438.    respective homing slots by the time you will normally try to look at
  439.    them (we hope).
  440.  
  441.    Note that homing area stack slots are always at *positive* offsets from
  442.    the frame pointer.  Thus, the homing area stack slots for the parameter
  443.    registers (passed values) for a given function are actually part of the
  444.    frame area of the caller.  This is unusual, but it should not present
  445.    any special problems for GDB.
  446.  
  447.    Note also that on the 88k, we are only interested in finding the
  448.    registers that might have been saved in memory.  This is a subset of
  449.    the whole set of registers because the standard calling sequence allows
  450.    the called routine to clobber many registers.
  451.  
  452.    We could manage to locate values for all of the so called "preserved"
  453.    registers (some of which may get saved within any particular frame) but
  454.    that would require decoding all of the tdesc information.  Tht would be
  455.    nice information for GDB to have, but it is not strictly manditory if we
  456.    can live without the ability to look at values within (or backup to)
  457.    previous frames.
  458. */
  459.  
  460. #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
  461.         frame_find_saved_regs (frame_info, &frame_saved_regs)
  462.  
  463.  
  464. /* There is not currently a functioning way to call functions in the
  465.    inferior.  */
  466.  
  467. /* But if there was this is where we'd put the call dummy.  */
  468. /* #define CALL_DUMMY_LOCATION AFTER_TEXT_END */
  469.  
  470. /* When popping a frame on the 88k (say when doing a return command), the
  471.    calling function only expects to have the "preserved" registers restored.
  472.    Thus, those are the only ones that we even try to restore here.   */
  473.  
  474. extern void pop_frame ();
  475.  
  476. #define POP_FRAME pop_frame ()
  477.  
  478. /* BCS is a standard for binary compatibility.  This machine uses it.  */
  479. #if !defined (BCS)
  480. #define BCS 1
  481. #endif
  482.